﻿
//删除html标记
function RemoveHtmlTag(str) {
    str = str.replace(/<\/?[^>]*>/g, ''); //去除HTML tag
    str = str.replace(/[ | ]*\n/g, '\n'); //去除行尾空白
    str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
    str = str.replace(/&nbsp;/ig, '');//去掉&nbsp;
    return str;

}
//验证金额
function CheckMoney(price) {
    var reg = /^(\d|[1-9]\d+)(\.\d+)?$/;
    if (!reg.test(price)) {
        return 1;//验证失败
    }
    return 0;
}
//验证邮箱
function CheckEmail(email) {
    var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
    if (!reg.test(email)) {
        return 1;//验证失败
    }
    return 0;
}
//验证电话号码
function CheckTell(tell) {
    var reg = /^1\d{10}$|^(0\d{2,3}-?|\(0\d{2,3}\))?[1-9]\d{4,7}(-\d{1,8})?$/;
    if (!reg.test(tell)) {
        return 1;//验证失败
    }
    return 0;
}

//验证正整数
function CheckZNum(num) {
   
    var reg = /^(\+|-)?\d+$/;
    if (!reg.test(num)) {
        return 1;//验证失败
    }
    return 0;
}
//验证qq
function CheckQQ(qq) {
    if (qq.length> 15) {
        return 1;
    }
    var reg = /^(\+|-)?\d+$/;
    if (!reg.test(qq)) {
        return 1;//验证失败
    }
   
    return 0;
}

//验证身份证
function CheckIdCard(idcard) {
    var reg = /^[1-9]{1}[0-9]{14}$|^[1-9]{1}[0-9]{16}([0-9]|[xX])$/;
    if (!reg.test(idcard)) {
        return 1;//验证失败
    }
    return 0;
}




